package com.beerandjesus.sportofkings.handicapper.model;

import org.apache.commons.lang.builder.ToStringBuilder;

import java.util.Map;
import java.util.HashMap;

/**
 * Date: Jun 8, 2012
 * Time: 1:48:38 PM
 */
public class AnalysisProfile {
    private int score = -1;
    private String description;
    private AnalysisProfileType type;

    private static final Map<AnalysisProfileType, String> DESCRIPTIONS = new HashMap<AnalysisProfileType, String>();

    static {
        DESCRIPTIONS.put(AnalysisProfileType.FIRST_OR_2ND_TURF_STARTER_WITH_PEDIGREE,
                "Horses trying turf for first or second time whose sires and/or dams' sires " +
                        "have shown strong turf pedigree are good bets.");
        DESCRIPTIONS.put(AnalysisProfileType.SECOND_TURF_START_AFTER_RETURNING_TO_DIRT,
                "Horses trying turf for the second time after returning to dirt have thier " +
                        "chances diminish greatly and are not good bets.");
        DESCRIPTIONS.put(AnalysisProfileType.SECOND_TURF_START_AFTER_WINNING_ON_TURF,
                "Horses having their second turf start after winning their first are " +
                        "generally good bets.");
        DESCRIPTIONS.put(AnalysisProfileType.SECOND_TURF_START_AFTER_LOSING_WITH_HONOR,
                "Horses having their second turf start after losing their first within one " +
                        "length of the winner are very good bets.");
        DESCRIPTIONS.put(AnalysisProfileType.DROP_IN_CLASS,
                "Denotes horses who are dropping in class from their previous race.");
        DESCRIPTIONS.put(AnalysisProfileType.CRAMER_DROP_IN_CLASS_WITH_JOCKEY_SWITCH,
                "Horses who are dropping in class and getting a favorable jockey switch can " +
                        "produce a .90 profit margin or more over the long term.");
        DESCRIPTIONS.put(AnalysisProfileType.CRAMER_DROP_IN_CLASS_POSS_JOCKEY_SWITCH,
                "Horses who are dropping in class and getting a favorable jockey switch can " +
                        "produce a .90 profit margin or more over the long term.");
    }

    public static AnalysisProfile getAnalysisProfile(AnalysisProfileType type, int score) {
        return new AnalysisProfile(type, DESCRIPTIONS.get(type), score);
    }

    private AnalysisProfile(AnalysisProfileType type, String description, int score) {
        this.type = type;
        this.description = description;
        this.score = score;
    }

    public int getScore() {
        return score;
    }

    public String getDescription() {
        return description;
    }

    public String getName() {
        return type.getName();
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        AnalysisProfile that = (AnalysisProfile) o;

        if (score != that.score) return false;
        if (type != that.type) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = score;
        result = 31 * result + (type != null ? type.hashCode() : 0);
        return result;
    }

    public String toString() {
        return new ToStringBuilder(this).append(type).append(score).toString();
    }
}
